package com.example.democlient;

import com.example.democlient.feign.DemoServerFeign;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@RestController
public class DemoClientApplication {

	public static void main(String[] args) {
		SpringApplication.run(DemoClientApplication.class, args);
	}



	// 如果配置成user.name的话就会取成操作系统用户名称了
	@Value("${admin.name}")
	private String adminName;

	@RequestMapping("/")
	public String welcome(){
		return "hello "+adminName;
	}

	@Autowired
	private DemoServerFeign demoServerFeign;

	@RequestMapping("/users")
	public List<Map<String,Object>> users(){
		return demoServerFeign.users();
	}
}
